//
//  SEGOrderTrackInfoModel.m
//  Uhomebk
//
//  Created by mac on 2017/10/9.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "SEGOrderTrackInfoModel.h"

@implementation SEGOrderTrackInfoModel
+ (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    return [[self alloc] initWithDictionary:dictionary];
}

- (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    self = [super init];
    if (self) {
       
        _trackId = @"";//serviceOrderId
        _trackCode = @"";
        _createDate = @"";
        _handleDate = @"";
        _trackStatus = @"";
        _overType = @"";
        _currentUser = [[NSArray alloc] init];
        _nextTrackCode = @"";
        _nextTrackName = @"";
        _nextUser = [[NSArray alloc] init];
        _dealAdvise = @"";
        _evalue = @"";
        _isAgree = @"2";
        _opUserType = @"";
        _charge = @"";
        _overTimeflag = @"";
        _trackName = @"";
        _trackDescIsOpen = @"0";
        _isLast = @"";
        _variables = [[NSArray alloc] init];
        _materiels = [[NSArray alloc] init];
        _payServices = [[NSArray alloc] init];
        _tasks = [[NSArray alloc] init];
        [self setValuesForKeysWithDictionary:dictionary];
        
        self.mDictionary = [[NSMutableDictionary alloc] initWithDictionary:dictionary];
        
    }
    return self;
}
-(void)setOpUserType:(NSString *)opUserType{
    _opUserType = [SEGUtils ValueToString:opUserType];
}
-(void)setTrackDescIsOpen:(NSString *)trackDescIsOpen
{
  _trackDescIsOpen = [SEGUtils ValueToString:trackDescIsOpen];
}

-(void)setTrackName:(NSString *)trackName{
   _trackName = [SEGUtils ValueToString:trackName];
}

-(void)setCharge:(NSString *)charge
{
   _charge = [SEGUtils ValueToString:charge];
}
-(void)setTrackId:(NSString *)trackId
{
     _trackId = [SEGUtils ValueToString:trackId];
}

-(void)setTrackCode:(NSString *)trackCode
{
    _trackCode = [SEGUtils ValueToString:trackCode];
}

-(void)setCreateDate:(NSString *)createDate
{
     _createDate = [SEGUtils ValueToString:createDate];
}

-(void)setHandleDate:(NSString *)handleDate
{
    _handleDate = [SEGUtils ValueToString:handleDate];
}

-(void)setTrackStatus:(NSString *)trackStatus
{
    _trackStatus = [SEGUtils ValueToString:trackStatus];
}

-(void)setOverType:(NSString *)overType
{
    _overType = [SEGUtils ValueToString:overType];
}

-(void)setNextTrackCode:(NSString *)nextTrackCode
{
    _nextTrackCode = [SEGUtils ValueToString:nextTrackCode];
}

-(void)setNextTrackName:(NSString *)nextTrackName
{
   _nextTrackName = [SEGUtils ValueToString:nextTrackName];
}

-(void)setDealAdvise:(NSString *)dealAdvise
{
    _dealAdvise = [SEGUtils ValueToString:dealAdvise];
}

-(void)setEvalue:(NSString *)evalue
{
    _evalue = [SEGUtils ValueToString:evalue];
}

-(void)setIsAgree:(NSString *)isAgree
{
    _isAgree = [SEGUtils ValueToString:isAgree];
}

-(void)setOverTimeflag:(NSString *)overTimeflag
{
    _overTimeflag = [SEGUtils ValueToString:overTimeflag];
}
- (void)setIsLast:(NSString *)isLast {
    _isLast = [SEGUtils ValueToString:isLast];
}

- (void)setValue:(id)value forUndefinedKey:(NSString*)key
{//注意此方法
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    
    if ([key isEqualToString:@"currentUser"] && [value isKindOfClass:[NSArray class]]) {
        __block NSMutableArray* _arrM = [NSMutableArray array];
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGOrderCurrentUser class]]){
                [_arrM addObject:obj];
            }else{
                SEGOrderCurrentUser* model = [SEGOrderCurrentUser initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        _currentUser = _arrM;
        return;
    }
    
    if ([key isEqualToString:@"nextUser"] && [value isKindOfClass:[NSArray class]]) {
        __block NSMutableArray* _arrM = [NSMutableArray array];
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGOrderCurrentUser class]]){
                [_arrM addObject:obj];
            }else{
                SEGOrderCurrentUser* model = [SEGOrderCurrentUser initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        _nextUser = _arrM;
        return;
    }
   
    if ([key isEqualToString:@"variables"] && [value isKindOfClass:[NSArray class]]) {
        __block NSMutableArray* _arrM = [NSMutableArray array];
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGTemplateModel class]]){
                [_arrM addObject:obj];
            }else{
                SEGTemplateModel* model = [SEGTemplateModel initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        _variables = _arrM;
        return;
    }
    
    if ([key isEqualToString:@"materiels"] && [value isKindOfClass:[NSArray class]]) {
        __block NSMutableArray* _arrM = [NSMutableArray array];
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGOrderMateriels class]]){
                [_arrM addObject:obj];
            }else{
                SEGOrderMateriels* model = [SEGOrderMateriels initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        _materiels = _arrM;
        return;
    }
    
    if ([key isEqualToString:@"payServices"] && [value isKindOfClass:[NSArray class]]) {
        __block NSMutableArray* _arrM = [NSMutableArray array];
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGOrderPayServices class]]){
                [_arrM addObject:obj];
            }else{
                SEGOrderPayServices* model = [SEGOrderPayServices initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        _payServices = _arrM;
        return;
    }
    
    if ([key isEqualToString:@"tasks"] && [value isKindOfClass:[NSArray class]]) {
        __block NSMutableArray* _arrM = [NSMutableArray array];
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGOrderTasks class]]){
                [_arrM addObject:obj];
            }else{
                SEGOrderTasks* model = [SEGOrderTasks initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        _tasks = _arrM;
        return;
    }
    
    [super setValue:value forKey:key];
    
}


@end



